﻿
@page "/Fin/OtherIncome/BatchEdit"
@using nERP.ViewModel.Fin.OtherIncomeVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
  <div style="margin-bottom:10px;"> @WtmBlazor.Localizer["Sys.BatchEditConfirm"]</div>
  <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
    <Select @bind-Value="@Model.LinkedVM.CustomerId" Items="AllCustomers" Id="g3d7253ec43fa4548bf8cb0cfa323f8be"/>
    <Select @bind-Value="@Model.LinkedVM.MakeUserId" Items="AllMakeUsers" Id="g3b0536db04c34184a00c813ecda8fd7f"/>
    <DateTimePicker @bind-Value="@Model.LinkedVM.InvoicesDate"/>
    <Select @bind-Value="@Model.LinkedVM.SettlementAccountId" Items="AllSettlementAccounts" Id="g84ee9cb377ed4200a5741885ac5a9684"/>
    <Select @bind-Value="@Model.LinkedVM.IncomeTypeId" Items="AllIncomeTypes" Id="g36d68f51d3c24f6a96369f817a4f2f4e"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.TotalPrice"/>
    <Select @bind-Value="@Model.LinkedVM.Status" Id="g6f91dfb0a82b4164aed83b8e2323c885"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.Remark"/>
  </Row>

  <div class="modal-footer table-modal-footer">
    <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
    <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
  </div>

</ValidateForm>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private OtherIncomeBatchVM Model = new OtherIncomeBatchVM();
    private ValidateForm vform { get; set; }
    
    private async Task Submit(EditContext context)
    {
        Model.Ids = ids;
        await PostsForm(vform, "/api/Fin/OtherIncome/BatchEdit", (s) => WtmBlazor.Localizer["Sys.BatchEditSuccess", s], method: HttpMethodEnum.POST);
    }
            

    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllCustomers = new List<SelectedItem>();
    private List<SelectedItem> AllMakeUsers = new List<SelectedItem>();
    private List<SelectedItem> AllSettlementAccounts = new List<SelectedItem>();
    private List<SelectedItem> AllIncomeTypes = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllCustomers = await WtmBlazor.Api.CallItemsApi("/api/Fin/OtherIncome/GetCustomers");
        AllCustomers.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllMakeUsers = await WtmBlazor.Api.CallItemsApi("/api/Fin/OtherIncome/GetFrameworkUsers");
        AllMakeUsers.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllSettlementAccounts = await WtmBlazor.Api.CallItemsApi("/api/Fin/OtherIncome/GetSettlementAccounts");
        AllSettlementAccounts.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllIncomeTypes = await WtmBlazor.Api.CallItemsApi("/api/Fin/OtherIncome/GetDicFields其他收入类别");
        AllIncomeTypes.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });

        await base.OnInitializedAsync();
    }
}
